#include "cesium/stages/filewriter.hpp"

namespace Cesium {

FileWriterStage::FileWriterStage(const std::string& filename)
 : Stage(),
   outputFileStream(filename.c_str(), std::ofstream::out | std::ofstream::binary)
{
}

FileWriterStage::~FileWriterStage() {
    outputFileStream.close();
}

void FileWriterStage::signal(Stage* src, Buffer* data, BufferRange range) {
    data->ref();
    outputFileStream.write( (const char*)data->raw() + range.begin, range.length);
    data->unref();
}

} // namespace Cesium
